package util;


/**
 * Created by liuwei54 on 2018/6/30.
 */
public class Compute {

    public static int findFirstLarger(long[] array, long key) {
        int left = 0;
        int right = array.length - 1;

        // 这里必须是 <=
        while (left <= right) {
            int mid = (left + right) / 2;
            if (array[mid] > key) {
                right = mid - 1;
            }
            else {
                left = mid + 1;
            }
        }
        return left;
    }





    public static void main(String[] args) {
        long[] arr ={1L,2L,8L,9L,9L,19L};
        long key =8L;
        System.out.println(findFirstLarger(arr,key));
    }
}
